//双色球系统:投注号码由6个红色球号码(1-33不能重复)和1个蓝色球号码(1-16可以与红球重合)组成
//中奖条件和奖金表:6+1一等奖最高1000万,6+0二等奖最高500万,5+1三等奖3000元,5+0或4+1四等奖200元,4+0或3+1五等奖10元
import java.util.Scanner;
import java.util.Random;
public class A17{
	public static void main(String[] args){
		//生成中奖号码
		int[] arr = createNumber();
		
		for(int i = 0;i < arr.length;i++){
			System.out.print(arr[i] + " ");
		}
		//用户输入密码
		int[] userInputArr = userInputNumber();
		//判断
		int redCount = 0;
		for(int i = 0;i < userInputArr.length-1;i++){
			for(int j = 0;j < arr.length-1;j++){
				if(userInputArr[i] == arr[j]){
					redCount++;
					break;
				}
			}
		}
		int blueCount = 0;
		if(userInputArr[userInputArr.length-1] == arr[arr.length-1]){
			blueCount = 1;
		}
		System.out.println("红色球中"+redCount+"个 蓝色球中"+blueCount+"个");
		if(redCount == 6 && blueCount == 1){
			System.out.println("恭喜中一等将1000万");
		}else if(redCount == 6 && blueCount == 0){
			System.out.println("恭喜中二等将500万");
		}else if(redCount == 5 && blueCount == 1){
			System.out.println("恭喜中三等将3000元");
		}else if((redCount == 5 && blueCount == 0) || (redCount == 4 && blueCount == 1)){
			System.out.println("恭喜中四等将200元");
		}else if((redCount == 4 && blueCount == 0) || (redCount == 3 && blueCount == 1)){
			System.out.println("恭喜中五等将10元");
		}else{
			System.out.println("谢谢惠顾");
		}
		
		
	}
	public static int[] userInputNumber(){
		int[] arr = new int[7];
		Scanner sc = new Scanner(System.in);
		for(int i = 0;i < arr.length-1;){
			System.out.println("请输入第"+(i+1)+"位号码");
			int redNumber = sc.nextInt();
			if(redNumber >= 1 && redNumber <= 33){
				boolean flag = contains(arr,redNumber);
				if(!flag){
				arr[i] = redNumber;
				i++;
				}else{
					System.out.println("输入号码重复,请重新输入");
				}
			}else{
				System.out.println("输入号码超出范围,请重新输入");
			}
		}
		while(true){
			System.out.println("请输入第7位号码");
			int blueNumber = sc.nextInt();
			if(blueNumber <= 16 && blueNumber >= 1){
				arr[arr.length-1] = blueNumber;
				break;
			}else{
				System.out.println("输入号码超出范围,请重新输入");
			}
		}
		return arr;
	}
	
	public static int[] createNumber(){
		int[] arr = new int[7];
		Random r = new Random();
		for(int i = 0;i < arr.length-1;){
			int redNumber = r.nextInt(33)+1;
			boolean flag = contains(arr,redNumber);
			if(!flag){
				arr[i] = redNumber;
				i++;
			}
		}
		int blueNumber = r.nextInt(16)+1;
		arr[arr.length-1] = blueNumber;
		return arr;
	}
	
	public static boolean contains(int[] arr,int number){
		for(int i = 0;i < arr.length-1;i++){
			if(arr[i] == number){
				return true;
			}
		}
		return false;
	}
	
	
}


